<?php

namespace common\exception;

use common\traits\InstanceTrait;
use think\Exception;

class ExceptionEmun extends BaseException
{
    use InstanceTrait;
}

class SystemException extends ExceptionEmun
{
    const INVALID_USE_REDIS = ['code' => 10001, 'msg' => '错误使用缓存'];
    const INVALID_OPERATE = ['code' => 10002, 'msg' => '非法操作',];
    const INVALID_PARAMETER = ['code' => 10003, 'msg' => '非法参数'];
    const EMPTY_CONFIG = ['code' => 10004, 'msg' => '加载配置项失败'];
    const CROS_CONFIG = ['code' => 10005, 'msg' => 'CROS成功'];
    const INVALID_ROUTE = ['code' => 10006, 'msg' => '非法路由地址'];
    const CREATE_FAILE = ['code' => 10007, 'msg' => '添加失败'];
    const UPDATE_FAILE = ['code' => 10008, 'msg' => '编辑失败'];
    const SPECIAL_ERROR = ['code' => 10009, 'msg' => '对不起,有一个特殊错误出现,请联系运营'];
    const NO_CAPTCHA = ['code' => 10010, 'msg' => '请输入验证码',];
    const CAPTCHA_ERROR = ['code' => 10011, 'msg' => '验证码错误',];
    const FIELD_CONFILICT = ['code' => 10012, 'msg' => '字段冲突',];
}

class FileException extends ExceptionEmun
{
    const FILE_ERROR = ['code' => 10100, 'msg' => '上传文件失败'];
    const FILE_SIZE = ['code' => 10101, 'msg' => '上传文件尺寸过大'];
    const FILE_SUFFIX = ['code' => 10102, 'msg' => '上传文件格式不正确'];

}

class TokenException extends ExceptionEmun
{
    const ILLEGAL_TOKEN = ['code' => 10201, 'msg' => '非法TOKEN,请重新获取',];
    const EXPIRED_TOKEN = ['code' => 10202, 'msg' => '过期TOKEN,请重新获取',];
    const ERROR_WX_API = ['code' => 10203, 'msg' => '获取SESSION_KEY及OPENID时异常，微信内部错误',];
}

class MemberException extends ExceptionEmun
{
    const NO_EXIST = ['code' => 10300, 'msg' => '账号不存在',];
    const INCORRECT_PASSWORD = ['code' => 10301, 'msg' => '密码错误',];
    const FREQUENT_REGISTER = ['code' => 10302, 'msg' => '注册过于频繁,请稍后再试',];
    const NO_RIGHT = ['code' => 10303, 'msg' => '帐号没有权限',];
    const LOCKED = ['code' => 10304, 'msg' => '帐号已被禁用',];
}

class AdminException extends ExceptionEmun
{
    const NO_EXIST = ['code' => 20000, 'msg' => '账号不存在',];
    const INCORRECT_PASSWORD = ['code' => 20001, 'msg' => '密码错误',];
    const FREQUENT_REGISTER = ['code' => 20002, 'msg' => '注册过于频繁,请稍后再试',];
    const NO_RIGHT = ['code' => 20003, 'msg' => '帐号没有权限',];
    const LOCKED = ['code' => 20004, 'msg' => '帐号已被禁用',];
    const NO_GROUP = ['code' => 20005, 'msg' => '至少勾选一个角色',];
    const UPDATE_ADMIN = ['code' => 20006, 'msg' => '不能操作超级管理员',];
    const NAME_REPEAT = ['code' => 20007, 'msg' => '用户名重复',];
    const PASSWORD_REPEAT = ['code' => 20008, 'msg' => '新旧密码不能相同',];

}

class PlanException extends ExceptionEmun
{
}

class MenuException extends ExceptionEmun
{
    const NO_EXIST = ['code' => 30000, 'msg' => '菜单不存在',];
    const NO_RIGHT = ['code' => 30001, 'msg' => '不能操作他人菜单',];
    const PID_NO_EXIST = ['code' => 30102, 'msg' => '父菜单不存在',];
    const PID_NO_RIGHT = ['code' => 30103, 'msg' => '父菜单不正确',];
    const NAME_REPEAT = ['code' => 30104, 'msg' => '菜单名重复',];
}

class StructureException extends ExceptionEmun
{
    const NO_EXIST = ['code' => 30100, 'msg' => '部门不存在',];
    const NO_RIGHT = ['code' => 30101, 'msg' => '无权操作部门',];
    const PID_NO_EXIST = ['code' => 30102, 'msg' => '父部门不存在',];
    const PID_NO_RIGHT = ['code' => 30103, 'msg' => '父部门不正确',];
    const NAME_REPEAT = ['code' => 30104, 'msg' => '部门名重复',];
}

class PostException extends ExceptionEmun
{
    const NO_EXIST = ['code' => 30200, 'msg' => '岗位不存在',];
    const NO_RIGHT = ['code' => 30201, 'msg' => '无权操作岗位',];
    const PID_NO_EXIST = ['code' => 30202, 'msg' => '父岗位不存在',];
    const PID_NO_RIGHT = ['code' => 30203, 'msg' => '父岗位不正确',];
    const NAME_REPEAT = ['code' => 30204, 'msg' => '岗位名重复',];
    const STRUCTURE_EMPTY = ['code' => 30205, 'msg' => '部门不存在',];
}

class CategoryException extends ExceptionEmun
{
    const NO_EXIST = ['code' => 30300, 'msg' => '分类不存在',];
    const NO_RIGHT = ['code' => 30301, 'msg' => '无权操作文章分类',];
    const NAME_REPEAT = ['code' => 30304, 'msg' => '文章分类名重复',];
}

class ArticleException extends ExceptionEmun
{
    const NO_EXIST = ['code' => 30400, 'msg' => '文章不存在',];
    const NO_RIGHT = ['code' => 30401, 'msg' => '无权操作文章',];
    const NAME_REPEAT = ['code' => 30404, 'msg' => '文章名重复',];
    const CATEGORY_EMPTY = ['code' => 30405, 'msg' => '文章分类不存在',];
}

class RuleException extends ExceptionEmun
{
    const NO_EXIST = ['code' => 30500, 'msg' => '权限不存在',];
    const PID_NO_EXIST = ['code' => 30501, 'msg' => '父权限不存在',];
    const PID_NO_RIGHT = ['code' => 30502, 'msg' => '父权限不正确',];
    const NAME_REPEAT = ['code' => 30503, 'msg' => '角色名重复',];
}

class GroupException extends ExceptionEmun
{
    const NO_EXIST = ['code' => 30600, 'msg' => '角色不存在',];
    const NAME_REPEAT = ['code' => 30601, 'msg' => '角色名重复',];
}



